<?php

namespace Admin\Controller;
use User\Api\UserApi;

class HornsController extends AdminController{
	
	public function index(){
		$info = M('Horns')->select();
		$this->assign('info',$info);
//		dump($info);
		$this->display();
	}
	public function horns_add($id){
		
		$buffing           = M("Buffing")->find($id);
		$map["product_id"] = $buffing['product_id'];
		$map["purchase_id"]= $buffing['purchase_id'];
		$map["create_time"]= time();
	    $map['buffing_id'] = $id;
		M('Horns')->add($map);
		$info = M('Horns')->select();
		$this->ajaxReturn($info);
		
	}
	public function search($id){
		$info =  M("horns")->find($id);
		$this->ajaxReturn($info);
		
	}
	public function add(){
		
		
		$map["id"]             	=  $_POST["horns_id"];
		$map["horns_weight"] 	=  $_POST["horns_weight"];
		$map["horns_price"] 	=  $_POST["horns_price"];
		$map["sell_contact_id"] =  $_POST["sell_contact_id"];
		$map["total_price"]     =  $_POST["horns_weight"] * $_POST["horns_price"];
//		$this->ajaxReturn($map);
		M("horns")->save($map);
		
	}
	public function del($id){
	   $data = M("Horns")->find($id);
//	   $this->ajaxReturn($data);
       $data["is_delete"] = 1;
	   M("Horns")->save($data);
	}
}
?>